package com.hb.trade.server.center.au.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hb.core.pojo.center.au.entity.ApiInfo;
import com.hb.core.pojo.center.au.mapper.ApiInfoMapper;
import com.hb.core.pojo.parent.MPCommonEntity;
import com.hb.trade.server.center.au.service.ApiInfoService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 项目中的所有接口信息 服务实现类
 * </p>
 *
 * @author zhaojk
 * @since 2022-03-22
 */
@Service
public class ApiInfoServiceImpl extends ServiceImpl<ApiInfoMapper, ApiInfo> implements ApiInfoService {

    @Override
    public ApiInfo getApiByName(String apiName) {
        if (StrUtil.isEmpty(apiName)) {
            return null;
        }
        QueryWrapper<ApiInfo> wrapper = ApiInfo.wrapper();
        wrapper.lambda().eq(ApiInfo::getApiName, apiName);
        return getOne(wrapper);
    }

    @Override
    public boolean exists(String apiName) {
        if (StrUtil.isEmpty(apiName)) {
            return false;
        }
        QueryWrapper<ApiInfo> wrapper = ApiInfo.wrapper();
        wrapper.lambda().eq(ApiInfo::getApiName, apiName);
        return count(wrapper) > 0;
    }
}
